import 'package:close_dialog/sliver_dragger_wrapper.dart';
import 'package:flutter/material.dart';

import 'dialog.dart';

class SliverExample extends StatefulWidget {
  @override
  _SliverExampleState createState() => _SliverExampleState();
}

class _SliverExampleState extends State<SliverExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      floatingActionButton: FloatingActionButton(onPressed: _showDialog),
    );
  }

  void _showDialog() {
    showMyDialog(
      context,
      SliverDraggerWrapper(
        height: 400,
        builder: (ctx) {
          return buildSliverList(ctx);
        },
      ),
    );
  }

  Widget buildSliverList(BuildContext ctx) {
    return SliverList(
      delegate: SliverChildBuilderDelegate(
        _buildItem,
      ),
    );
  }

  Widget _buildItem(BuildContext context, int index) {
    return Container(
      color: Colors.white,
          child: ListTile(
        title: Text(index.toString()),
      ),
    );
  }
}
